package com.bafa.objects;

import java.io.Serializable;

import com.bafa.services.RetrieveServices;

public class Scorer implements Serializable{

	private String name;
	private int goals;
	private int teamId;
	private int seasonId;
	
	public Scorer(com.bafa.objects.schema.Scorer scorer){
		if(scorer!=null){
			name = scorer.getName().replaceAll("&apos;","'");
			this.name = name;
			this.goals=scorer.getGoals();
			this.teamId=scorer.getTeamId();
			this.seasonId=scorer.getSeasonId();
		}
		
	}
	
	public Scorer(String name, int goals, int teamId, int seasonId) {
		name = name.replaceAll("&apos;","'");
		this.name = name;
		this.goals=goals;
		this.teamId=teamId;
		this.seasonId=seasonId;
	}
	public boolean equals(Scorer scorer){
		return this.getName().equals(scorer.getName());
	}

	public int getGoals() {
		return goals;
	}

	public String getName() {
		return name;
	}
	
	public String getTeamName(){
		return RetrieveServices.getTeam(""+teamId).getName();
	}
	
	public String getSeason(){
		return RetrieveServices.getSeason(""+seasonId).getName()+" "+RetrieveServices.getSeason(""+seasonId).getYear();
	}
	
	public String toXML(){
		StringBuffer xml = new StringBuffer();
		xml.append("<scorer>");
		xml.append("<name>");
		xml.append(name);
		xml.append("</name>");
		xml.append("<teamName>");
		xml.append(getTeamName());
		xml.append("</teamName>");
		xml.append("<goals>");
		xml.append(goals);
		xml.append("</goals>");
		xml.append("</scorer>");
		
		return xml.toString();
	}
	public int getSeasonId() {
		return seasonId;
	}

	public int getTeamId() {
		return teamId;
	}

	public void setTeamId(int teamId) {
		this.teamId = teamId;
	}

	public void setGoals(int goals) {
		this.goals = goals;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setSeasonId(int seasonId) {
		this.seasonId = seasonId;
	}
}
